<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <title>关键帧动画</title>
</head>
<body>
    <style>
        @keyframes animation1 {
            0% {
                background-color: red;
                width: 100px;
                height: 100px;
            }
            25% {
                background-color: orchid;
                width: 200px;
                height: 200px;
            }
            75% {
                background-color: green;
                width: 150px;
                height: 150px;
            }
            100% {
                background-color: blue;
                width: 200px;
                height: 200px;
            }
        }
        .demo {
            width: 100px;
            height: 100px;
            background-color: red;

            
        }
        .demo-ani {
            /* 设置关键帧动画名称 */
            animation-name: animation1;
            /* 设置动画时长 */
            animation-duration: 3s;
            /* 设置动画播放方式：渐入渐出 */
            animation-timing-function: ease-in-out;
            /* 设置动画播放的方向 */
            animation-direction: alternate;
            /* 设置动画播放的次数 */
            animation-iteration-count: infinite;
            /* 设置动画的播放状态 */
            animation-play-state: running;
            /* 设置播放动画的延迟时间 */
            animation-delay: 1s;
            /* 设置动画播放结束应用到元素的样式 */
            animation-fill-mode:forwards;
            width: 200px;
            height: 200px;
            background-color: blue;
        }
    </style>
    <div id="Application">  
        <div :class="cls" @click="run">

        </div>   
    </div>
    <script>
        const App = Vue.createApp({
            data(){
                return {
                    cls:"demo"
                }
            },
            methods: {
                run() {
                    if (this.cls == "demo") {
                        this.cls = "demo-ani"
                    } else {
                        this.cls = "demo"
                    }
                }
            }
        })
        App.mount("#Application") 
    </script>
</body>
</html>